class StartNode extends CoolNode
{
	public constructor() 
	{
		super();
		this.init();
	}
	private m_board:egret.Bitmap;
	private m_Callback:Function;
	private m_Obj:egret.DisplayObjectContainer;
	private m_effectId:number;
	public setCallback(callback:Function, obj:egret.DisplayObjectContainer)
	{
		this.m_Callback = callback;
		this.m_Obj = obj;
	}
	private init()
	{
		this.initBg();
		//this.initText();
		this.initBtn();
	}
	public playEffect()
	{
		
	}
	public stopEffect()
	{
		SoundEngine.getInstance().stopEffect(this.m_effectId);
	}

	private initBg()
	{
		let bg = this.createBitmapByName("black");
		bg.alpha = 0.7;
		this.addChild(bg);
		bg.touchEnabled = true;//截取事件
		// let board = this.createBitmapByName("tishi_k");
		// board.anchorOffsetX = board.width / 2;
		// board.anchorOffsetY = board.height / 2;
		// board.x = this.width / 2;
		// board.y = this.height / 2;
		// this.addChild(board);
		// this.m_board = board;
		// let title = this.createBitmapByName("begin_jpg");
		// title.anchorOffsetX = title.width / 2;
		// title.anchorOffsetY = title.height / 3;
		// title.x = this.width / 2;
		// title.y = this.height / 2 - board.height / 24 * 11;
		// this.addChild(title);
	}
	// private initText()
	// {
	// 	let text = new egret.TextField();
	// 	//text.text = textString;
	// 	text.textAlign = egret.HorizontalAlign.CENTER;
	// 	text.verticalAlign = egret.VerticalAlign.MIDDLE;
	// 	text.size = 26;
	// 	text.textColor = 0xaa5a34;
	// 	text.fontFamily = "FangSong";
		
		
	// 	if(text.width > this.m_board.width / 6 * 5)
	// 	{
	// 		text.width = this.m_board.width / 6 * 5;
	// 		text.height = this.m_board.height / 3;
	// 		text.textAlign = egret.HorizontalAlign.LEFT;
	// 	}

	// 	text.x = this.width / 2;
	// 	text.y = this.height / 2 - this.m_board.width / 30;
	// 	text.anchorOffsetX = text.width / 2;
	// 	text.anchorOffsetY = text.height / 2;
	// 	//text.background = true;
	// 	//text.backgroundColor = 0x000000;
	// 	this.addChild(text);
	// }

	private initBtn()
	{
		let startBtn = this.createBtnByName("begin",this.clickStart,this);
		startBtn.x = this.width / 2;
		startBtn.y = this.height / 2;
		this.addChild(startBtn);
	}
	private clickStart(event:egret.Event)
	{
		let t = SoundEngine.getInstance().playEffect("right_mp3",1);
		SoundEngine.getInstance().setVolume(t, 0);

		let callback = this.m_Callback.bind(this.m_Obj);
		callback();
	}
}